package com.ljl.mvvmdemo.net

import android.text.TextUtils
import com.ljl.mvvmdemo.bean.SystemBookProxy

/**
 * created by luojialun on 2024/10/11
 */
object HttpConstants {

    const val ENVIRONMENT_TEST = 0
    const val ENVIRONMENT_RELEASE = 1

    const val AREA_CHINA = 0
    const val AREA_SINGAPORE = 1

    var environment = ENVIRONMENT_TEST
    var area = AREA_CHINA

    var BASE_URL = "http://"  //接口请求地址
    var SYSTEM_BOOK_PROXY_URL = "http://" //派单地址

    var HW_SIGN_SECRET = "" //华为密钥
    var BOOK_PROXY_DEPLOY_ENVIRONMENT = "" //华为环境
    var BOOK_PROXY_POS_GATEWAY_URL = ""  //华为网关

    init {
        initUrl(null, environment)
    }

    fun initUrl(systemBookProxy: SystemBookProxy?, environment: Int) {
        if (environment == ENVIRONMENT_RELEASE) {
            //正式
            SYSTEM_BOOK_PROXY_URL = if (area == AREA_CHINA) {
                "https://homeland.lemeng.center/homeland-desk/"
            } else {
                "https://desk.nhsoftcloud.com/ServiceDesk/"
            }

            HW_SIGN_SECRET = "c33f8956507a6e594c35e1cde0f486e7694896f6b92a479269acd81b205c0671"
        } else {
            //测试
            SYSTEM_BOOK_PROXY_URL = "http://csp.nhsoft.cn/ServiceDesk/"

            HW_SIGN_SECRET = "8f2303f8d116d40699e20707d605f4933c86c5b4b35dff61266823ef64b61fe6"
        }


        systemBookProxy?.run {
            BASE_URL = if (!TextUtils.isEmpty(bookProxyPosGatewayUrl)) {
                //华为网关
                BOOK_PROXY_POS_GATEWAY_URL = bookProxyPosGatewayUrl
                BOOK_PROXY_DEPLOY_ENVIRONMENT = bookProxyDeployEnvironment
                "$bookProxyPosGatewayUrl/amazon-pos/customer/"
            } else if (!TextUtils.isEmpty(bookProxyEarthGatewayUrl)) {
                //AMA网关
                "$bookProxyEarthGatewayUrl/amazon-pos/customer/"
            } else if (bookProxyPosAPI.contains("http")) {
                //非网关
                "$bookProxyPosAPI/customer/"
            } else {
                "http://$bookProxyPosAPI/customer/"
            }
        }
    }
}